//"class" Rectangle, for view and camera boundaries

function Rectangle(left, top, width, height){
	
	//rectangle variables
	this.left = left || 0;
	this.top = top || 0;
	this.right = (left + width) || 0;
	this.bottom = (top + height) || 0;		
		
	//sets the rectangle
	Rectangle.prototype.set = function(left, top, /*optional*/width, /*optional*/height){
		this.left = left;
        this.top = top;
        this.width = width || this.width;
        this.height = height || this.height;
        this.right = (this.left + this.width);
        this.bottom = (this.top + this.height);
		};
		
	// checks if this rectangle is within another	
	Rectangle.prototype.within = function(r) {
		return (r.left <= this.left && 
				r.right >= this.right &&
				r.top <= this.top && 
				r.bottom >= this.bottom);
	};	
		
	//checks if this rectangle is overlapses another	
	Rectangle.prototype.overlaps = function(r) {
		return (this.left < r.right && 
				r.left < this.right && 
				this.top < r.bottom &&
				r.top < this.bottom);
	};
};	